package cate.game.play.skill.passive.talent;

import cate.game.play.buff.Buff;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 被控制时恢复自身最大生命值的5%恢复效果，每回合仅生效1次
 */
public class 抗控PH extends PassiveHandler {

	private double 系数;

	//系数=500
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		系数 = args.getWDouble("系数", 0d);
	}

	private boolean heal;

	@Override
	public void onRoundBegin(ActionCtx action) {
		heal = false;
	}

	@Override
	public void onOtherAddBuff(ActionCtx action, Buff otherBuff) {
		if (heal) {
			return;
		}
		if (otherBuff.isCtrl()) {
			heal = true;
			skill.owner.attr.passiveHeal(action, skill.owner, skill.owner.attr.total().hpTotal() * 系数);
		}
	}
}
